package com.hzya.frame.utils.help;

import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Encoder;

import java.io.IOException;

/**
 * @description:
 * @author: gjh
 * @Date Created in 2018/6/25 9:38
 */
public class MultipartFileHelper {
    /***
     * 传入一个file 获取base64字符
     * @param file
     * @return
     * @throws IOException
     */
    public static String getIcodBase64(MultipartFile file) throws IOException {
        String iconBase64 = null;
        BASE64Encoder encoder = new BASE64Encoder();
        byte[] bytes = file.getBytes();
        iconBase64 = encoder.encode(bytes);
        return iconBase64;
    }
}
